home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Add-Ons / 4D / ComboBox 1.1.1 / src / ExtRoutines.c < prev    next >
Encoding:
Text File  |  1996-01-11  |  2.5 KB  |  100 lines  |  [TEXT/CWIE]

  1. //---------------------------------------------------------------------------------------
  2. //
  3. //    ExtRoutines.c -- Support routines for creating 4D extensions
  4. //
  5. //    Copyright ©1995-1996, Pensacola Christian College
  6. //
  7. //    ======================================================================
  8. //    Change History
  9. //    ======================================================================
  10. //
  11. //    1.0            08/  /95        Steve Dwire
  12. //                                            Initial release
  13. //
  14. //    1.1            11/17/95        Steve Dwire
  15. //                                            Added PostKey code from ACIUS's POSTKEY sample extension.
  16. //
  17. //---------------------------------------------------------------------------------------
  18.  
  19. #include "ExtRoutines.h"
  20.  
  21.  
  22. #if defined(powerc) || WINVER
  23. Call4DProcPtr gCall4DAdr;
  24.  
  25. void InitExtension(PackagePtr params)
  26. {
  27.     // While running on a PowerPC chip or on a Windows station,
  28.     // 4D passes the Call4D address at the InitPackage time:
  29.     gCall4DAdr = ((PackInitPtr)params)->fCall4D;
  30. }
  31. #endif
  32.  
  33. SWORD GetResID(OSType bType, OSType rType, SWORD localID)
  34. {
  35.     SWORD index, globalID;
  36.     ResTabHdl bundle;
  37.     ParameterBlock block;
  38.     
  39.     CALL4D(kEX_GET_RESID, &block);
  40.  
  41.     bundle = (ResTabHdl)GetResource(bType, block.fParam1);
  42.     if (bundle)
  43.     {
  44.         for (index = 0, globalID = 0; index < (*bundle)->fNumber; index++)
  45.         {
  46.             if(((*bundle)->fEntries[index].fType == rType) &&
  47.                  ((*bundle)->fEntries[index].fLocalID == localID))
  48.                 globalID = (*bundle)->fEntries[index].fGlobalID;
  49.         }
  50.         HPurge((Handle)bundle);
  51.     }
  52.     return globalID;
  53. }
  54.  
  55. #if defined(powerc) || WINVER
  56. OSErr LaunchNativeProcess (XPOINTER funcName, SLONG stack, UBYTE *procName, SLONG *procID)
  57. {
  58.     ParameterBlock    block;
  59.     
  60.     block.fH             = (XHANDLE) funcName;
  61.     block.fParam3    = stack;
  62.     Pstrcpy(procName,block.fS);
  63.     CALL4D(kEX_NEW_PROCESS_PPC, &block);
  64.     *procID = block.fParam1;
  65.     return block.fError;
  66. }
  67. #else
  68. OSErr Launch68KProcess (SLONG resType, SLONG resID, SLONG stack, UBYTE *procName, SLONG *procID)
  69. {
  70.     ParameterBlock    block;
  71.     XHANDLE                    procResource;
  72.     
  73.     procResource = GetResource(resType,GetResID('4BNX',resType,resID));
  74.     
  75.     HNoPurge(procResource);
  76.     HLock(procResource);
  77.     
  78.     block.fH            = (XHANDLE) *procResource;
  79.     block.fParam3    = stack;
  80.     Pstrcpy(procName,block.fS);
  81.     CALL4D(kEX_NEW_PROCESS, &block);
  82.     *procID = block.fParam1;
  83.     return block.fError;
  84. }
  85. #endif
  86.  
  87. void PostKey( unsigned long TheKey, unsigned long TheModifiers, Boolean useAutoKey)
  88. {
  89.     OSErr      TheErr;
  90.     long      TheMessage;
  91.     EvQEl    *TheQElPtr;
  92.  
  93.     TheMessage = TheKey & charCodeMask;
  94.     if (useAutoKey)
  95.         TheErr = PPostEvent(autoKey,TheMessage,&TheQElPtr);
  96.     else
  97.         TheErr = PPostEvent(keyDown,TheMessage,&TheQElPtr);
  98.     TheQElPtr->evtQModifiers = TheModifiers;
  99. }
  100.